#define DEBUG
#include <cstdio>

using namespace std;

const int maxm=1000000, mods=998244353;

long long qpower(long long a, int n) {
	long long s=1;
	for (; n>1; n/=2) {
		if (n%2) {
			s = s*a%mods;
		}
		a = a*a%mods;
	}
	return a*s%mods;
}

int lowbit(int o) {
	return o&(-o);
}

void addSum(long long *a, int o, long long v, int n) {
	for (; o<=n; o+=lowbit(o)) {
		a[o]+=v;
	}
}

long long getSum(long long *a, int o) {
	long long ret=0;
	for (; o>0; o-=lowbit(o)) {
		ret += a[o];
	}
	return ret;
}

long long solve(long long *suma, long long *sumb, int m) {
	long long ans=0;
	int d;
	for (int l=0, r=m, mid; l<=r; ) {
		mid=(l+r)/2;
		if (-2LL*mid*(getSum(suma, m)-getSum(suma, mid))+getSum(sumb, m)-2LL*getSum(sumb, mid)>=0) {
			d = mid;
			l = mid+1;
		} else {
			r = mid-1;
		}
	}
	ans = ((2*(getSum(sumb, d)%mods)%mods-(getSum(sumb, m)%mods)+mods)%mods*
		qpower((mods-2)*(((getSum(suma, m)+mods)%mods-
						(getSum(suma, d)+mods)%mods+mods)%mods)%mods, mods-2)%mods)%mods;
	return ans;
}

int main() {
	freopen("c.in", "r", stdin);
	freopen("c.out", "w", stdout);

	static long long w[maxm+1], suma[maxm+1], sumb[maxm+1];
	int m;
	scanf("%d", &m);
	for (int i=1; i<=m; i++) {
		scanf("%lld", w+i);
		addSum(suma, i, w[i], m);
		addSum(sumb, i, w[i]*i, m);
	}

	int q;
	scanf("%d", &q);
	for (int i=1; i<=q; i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		addSum(suma, x, y-w[x], m);
		addSum(sumb, x, y*x-x*w[x], m);
		w[x] = y;

		printf("%lld\n", solve(suma, sumb, m));
	}

	fclose(stdin);
	fclose(stdout);
	return 0;
}
